<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<c:set var="module" value="ad"/>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
		<form action="${ctx }/admin/ad/save?id=${n.id }" id="detail-form" class="form-horizontal" method="post">
			<div class="form-group">
                 <label class="col-sm-2 control-label">描述</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="description" value="${n.description }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">类型</label>
                 <div class="col-sm-10" id="typeChoose">
                 ${enum:detail('AdType', 'type', n.type) }
                 </div>
             </div>	
             <div class="form-group" <c:if test="${n.type!=adType && n.type != upAdType }">style="display:none"</c:if> id="productCategoryId">
                <label class="col-sm-2 control-label">商品分类</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="productCategory.id" value="${n.productCategory.id }"> --%>
                 	<input type="hidden" id="productCategory-id" name="productCategory.id" value="${n.productCategory.id }" class="form-control">
                 	<input type="text" placeholder="商品分类" class="form-control" id="productCategory-name" name="productCategory.name" value="${n.productCategory.name }" 
                 		onclick="bringTree({
						                 	url:'${ctx}/admin/productCategory/root?level=1',
						                 	name: 'name',
						                 	idInput: 'productCategory-id',
						                 	nameInput: 'productCategory-name'
						                 	})" />
                 </div>
             </div>
			<div class="form-group">
                 <label class="col-sm-2 control-label">状态</label>
                 <div class="col-sm-10">
                 	${enum:detail('AdStatus', 'status', n.status) }
                 </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-2 control-label">顺序</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="seq" value="${n.seq }">(*数字越小越靠前)
                 </div>
             </div>	
             <div class="form-group">
                 <label class="col-sm-2 control-label">URL</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="url" value="${n.url }">
                 </div>
             </div>		
               <div class="form-group">
                 <label class="col-sm-2 control-label">文本</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="text" value="${n.text }">
                 </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-2 control-label">子文本</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="subText" value="${n.subText }">
                 </div>
             </div>		
             <div class="form-group">
                 <label class="col-sm-2 control-label">颜色</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="color" value="${n.color }">
                 </div>
             </div>		
			<div class="form-group">
                 <label class="col-sm-2 control-label">图片</label>
                 <%-- <div class="col-sm-10">
                 	<input type="text" class="form-control" name="image" value="${n.image }">
                 </div> --%>
                 <div class="col-sm-10">
		            <input type="hidden" name="image" id="image" value="${n.image }" />
                 	<div class="my-images" single="true" images="${n.image }" id="image1" field="image">
                 	</div>
                 </div>
             </div>	
        	
		</form>
</div>

<%@include file="/common/foot.jsp" %>

</body>
<script type="text/javascript">
$(document).ready(function() {
	init_images('image1');
});
$("select[name=type]").change(function(){
	var type = $(this).val();
	var adType = ${adType};
	var upAdType = ${upAdType};
	if (type==adType || type  == upAdType) {
		$('#productCategoryId').show();
	} else {
		$('#productCategoryId').hide();
	}
});
</script>
</html>
